package com.gc.controller;

import com.gc.pojo.Resume;
import com.gc.service.ResumeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RequestMapping("/resume")
@Controller
public class ResumeController {

    @Autowired
    private ResumeService resumeService;

    /**
     * 查找所有数据
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "findAll",method = RequestMethod.GET)
    public List<Resume> findAll() {
        return resumeService.findAll();
    }

    /**
     * 查询单个数据
     * @param id
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "get/{id}", method = RequestMethod.GET)
    public Resume get(@PathVariable(value = "id") Long id) {
        Resume resume = resumeService.findById(id);
        return  resume;
    }


    /**
     * 删除单条数据
     * @param
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "delete/{id}",method = RequestMethod.GET)
    public Boolean deleteById( @PathVariable(value = "id") Long id ) {
        resumeService.deleteById(id);
        return  true;
    }

    /**
     * 增加 或者 修改 单条数据
     * @param resume
     * @return
     */
    @ResponseBody
    @RequestMapping("/save")
    public Boolean save(@RequestBody Resume resume) {
        Resume save = resumeService.save(resume);
        if (save==null){
            return  false;
        }
        return  true;
    }



}
